package com.gitee.wsl.func.ext

import com.gitee.wsl.func.BiCallAbleFun
import com.gitee.wsl.func.CallAbleFun
import com.gitee.wsl.func.RunWithResultFun
import com.gitee.wsl.func.SuspendBiCallAbleFun
import com.gitee.wsl.func.SuspendCallAbleFun
import com.gitee.wsl.func.SuspendRunWithResultFun
import kotlin.jvm.JvmName

infix fun <P1, P2, IP, R> BiCallAbleFun<P1,P2,IP>.andThen(f:  CallAbleFun<IP,R>): BiCallAbleFun<P1,P2,R> =
    { p1, p2 -> f(this(p1, p2)) }

infix fun <P1, P2, IP, R> BiCallAbleFun<P1,P2,IP>.andThen(f:  SuspendCallAbleFun<IP,R>): SuspendBiCallAbleFun<P1,P2,R> =
    { p1, p2 -> f(this(p1, p2)) }


infix fun <P1, P2, IP, R> SuspendBiCallAbleFun<P1,P2,IP>.andThen(f:  SuspendCallAbleFun<IP,R>): SuspendBiCallAbleFun<P1,P2,R> =
    { p1, p2 -> f(this(p1, p2)) }

@JvmName("SuspendBiCallAbleFun1")
infix fun <P1, P2, IP, R> SuspendBiCallAbleFun<P1,P2,IP>.andThen(f:  CallAbleFun<IP,R>): SuspendBiCallAbleFun<P1,P2,R> =
    { p1, p2 -> f(this(p1, p2)) }



infix fun <IP, R> RunWithResultFun<IP>.andThen(f: CallAbleFun<IP,R>): RunWithResultFun<R> =
    { f(this()) }

infix fun <IP, R> RunWithResultFun<IP>.andThen(f: SuspendCallAbleFun<IP,R>): SuspendRunWithResultFun<R> =
    { f(this()) }

infix fun <IP, R> SuspendRunWithResultFun<IP>.andThen(f: SuspendCallAbleFun<IP,R>): SuspendRunWithResultFun<R> =
    { f(this()) }

@JvmName("SuspendRunWithResultFun1")
infix fun <IP, R> SuspendRunWithResultFun<IP>.andThen(f: CallAbleFun<IP,R>): SuspendRunWithResultFun<R> =
    { f(this()) }




infix fun <P1, IP, R> CallAbleFun<P1,IP>.andThen(f: CallAbleFun<IP,R>): CallAbleFun<P1,R> =
    { p1 -> f(this(p1)) }

infix fun <P1, IP, R> CallAbleFun<P1,IP>.andThen(f: SuspendCallAbleFun<IP,R>): SuspendCallAbleFun<P1,R> =
    { p1 -> f(this(p1)) }

@JvmName("SuspendCallAbleFun1")
infix fun <P1, IP, R> SuspendCallAbleFun<P1,IP>.andThen(f: CallAbleFun<IP,R>): SuspendCallAbleFun<P1,R> =
    { p1 -> f(this(p1)) }

